package huoye.shops.huoye.home.presenter;


import android.os.CountDownTimer;

import huoye.shops.base.BasePresenter;
import huoye.shops.base.MineBaseJsonRequestCallback;
import huoye.shops.huoye.home.model.MerchantCenter;
import huoye.shops.huoye.home.model.ValidateMsg;
import huoye.shops.huoye.home.networt.HomeService;
import huoye.shops.huoye.home.view.IHomeView;
import huoye.shops.huoye.operation.model.ObtainShopType;


/**
 * Created by uesr on 2017/7/19.
 */

public class HomePresenter extends BasePresenter<IHomeView> {



    private HomeService mService;

    //商家管理后台主页
    public void postMerchantCenter(String type){
        //   view.showProcessingIndicator();
        mService.postMerchantCenter(type, new MineBaseJsonRequestCallback<MerchantCenter>(MerchantCenter.class) {


            @Override
            public void onSuccess(MerchantCenter merchantCenter) {
                super.onSuccess(merchantCenter);
                view.setData(merchantCenter);

            }

            //网络请求失败
            @Override
            public void onFailure(String msg, String code, Throwable e) {
                super.onFailure(msg, code, e);
                view.makeToast(msg);
            }

            //加载结束
            @Override
            public void onNetworkFail() {
                super.onNetworkFail();
                view.onNetworkFail();
            }

            //加载中
            @Override
            public void onFinish() {
                super.onFinish();
                view.hideProcessingIndicator();
            }
        });
    }



    //核销接口
    public void postValidateAll(String type,String itemId,String userId,String num){
        mService.postValidateAll(type,itemId,userId,num, new MineBaseJsonRequestCallback<ValidateMsg>(ValidateMsg.class) {

            @Override
            public void onSuccess(ValidateMsg validateMsg) {
                super.onSuccess(validateMsg);
                view.makeToast(validateMsg.getMsg());
            }

            //网络请求失败
            @Override
            public void onFailure(String msg, String code, Throwable e) {
                super.onFailure(msg, code, e);
                view.makeToast(msg);
            }

            //加载结束
            @Override
            public void onNetworkFail() {
                super.onNetworkFail();
                view.onNetworkFail();
            }

            //加载中
            @Override
            public void onFinish() {
                super.onFinish();
                view.hideProcessingIndicator();
            }
        });
    }












    @Override
    public void onStart() {
        mService = new HomeService();
    }

}
